package com.ferry.serial.api;

/**
 * Created by daiyong
 */
public abstract class Serializer {

	/**
	 * 最大缓冲size
	 */
	public static final int MAX_CACHED_BUF_SIZE = 256 * 1024;

	/**
	 * 默认缓冲size
	 */
	public static final int DEFAULT_BUF_SIZE = 512;

	/**
	 * 标识
	 * @return
	 */
	public abstract int code();

	public abstract <T> OutputBuf writeObject(OutputBuf outputBuf, T obj);

	public abstract <T> byte[] writeObject(T obj);

	public abstract <T> T readObject(InputBuf inputBuf, Class<T> cls);

	public abstract <T> T readObject(byte[] bytes, int offset, int length, Class<T> cls);

	public <T> T readObject(byte[] bytes, Class<T> cls) {
		return readObject(bytes, 0, bytes.length, cls);
	}




}
